﻿using UnityEngine;
using System.Collections;

public class WriteSomething : MonoBehaviour {
	public bool isFinishProgress;
	[SerializeField] TextAsset textAsset;
	[SerializeField] GameObject UIPrefab;
	GameObject writeUI;
	ReadTextExample rte;
	string content;
	int i = 0;
	// Use this for initialization
	void Start () {
		writeUI = GameObject.Instantiate (UIPrefab, transform.position + new Vector3 (0, 1, 0), transform.rotation) as GameObject;
		rte = writeUI.GetComponent<ReadTextExample> ();
		content = textAsset.text;
	}
	
	// Update is called once per frame
	void Update () {
		if (i >= content.Length) {
			isFinishProgress = true;
			Destroy (writeUI);
			gameObject.SetActive (false);
			return;
		}
		if (MyInput.GetInputOfType (InputType.WRITING)) {
			rte.WordText.text += content [i++];
		}
	}
}
